# coding:utf-8
"""
Author: r.xw
Date: 2024/1/1
File: index.py
"""
import logging

from flask import Blueprint, render_template, request

from app.config.config import config
from app.settings import env
from model.article import Article

index = Blueprint('index', __name__)


@index.route('/')
def home():
    # 获取参数page
    page = request.args.get('page')
    logging.debug(f'page:{page}')
    # 获取article list
    articles = Article().get_list(page)
    for article in articles:
        article.article_image = config[env].image_path + '/1.png'
    # 渲染
    return render_template('index.html', articles=articles)
